package sqite

import (
	"Readme/initialine"
	"Readme/model"
)

func LoginUser(mobile string, password string) (user model.User, err error) {
	err = initialine.DB.Where("mobile=?", mobile).Where("password=?", password).Find(&user).Error
	if err != nil {
		return model.User{}, err
	}
	return user, nil
}

func ListFocu(id int) (focu model.Focu, err error) {
	err = initialine.DB.Where("user_id=?", id).Find(&focu).Error
	if err != nil {
		return model.Focu{}, err
	}
	return focu, nil
}

func AddFriend(id int) (friend model.Friend, err error) {
	friend = model.Friend{
		UserId: id,
		Type:   1,
	}
	err = initialine.DB.Create(&friend).Error
	if err != nil {
		return model.Friend{}, err
	}
	return friend, nil
}
